
package com.yimixian.app.order;

import com.yimixian.app.R;
import com.yimixian.app.model.Order;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class OrderStatusItemView extends FrameLayout {

    @InjectView(R.id.iv_top)
    ImageView mIvTop;
    @InjectView(R.id.iv_icon)
    ImageView mIvIcon;
    @InjectView(R.id.iv_bottom)
    ImageView mIvBottom;
    @InjectView(R.id.tv_status)
    TextView mTvStatus;
    @InjectView(R.id.tv_status_detail)
    TextView mTvStatusDetail;
    @InjectView(R.id.tv_time)
    TextView mTvTime;

    public OrderStatusItemView(Context context) {
        super(context);

        initOrderListItemView();
    }

    public OrderStatusItemView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initOrderListItemView();
    }

    public OrderStatusItemView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initOrderListItemView();
    }

    private void initOrderListItemView() {

        LayoutInflater.from(getContext()).inflate(R.layout.order_status_item, this);
        ButterKnife.inject(this);

    }

    public void bind(Order.orderStatus order) {
        mTvStatus.setText(order.name);
        mTvStatusDetail.setText(order.desc);
        mTvTime.setText(order.date);
        if (order.active) {
            mTvStatus.setTextColor(getResources().getColor(R.color.good_detail_title_red));
            mTvStatusDetail.setTextColor(getResources().getColor(R.color.good_detail_title_red));
            mTvTime.setTextColor(getResources().getColor(R.color.good_detail_title_red));
            mIvIcon.setImageResource(R.drawable.ic_current_point);
        } else {
            mTvStatus.setTextColor(getResources().getColor(R.color.my_text_title));
            mTvStatusDetail.setTextColor(getResources().getColor(R.color.my_text_title));
            mTvTime.setTextColor(getResources().getColor(R.color.my_text_title));
            mIvIcon.setImageResource(R.drawable.ic_nomal_point);
        }
    }

    public void hideTopLine() {
        mIvTop.setVisibility(View.INVISIBLE);
    }

    public void hideBottomLine() {
        mIvBottom.setVisibility(View.INVISIBLE);
    }
}
